package nine;
import java.util.Objects;
import java.util.Scanner;

class Point {
    private int x;
    private int y;
    public Point() {
    }
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
    public int getX() {
        return x;
    }
    public void setX(int x) {
            this.x = x;
            }
    public int getY() {
            return y;
            }
    public void setY(int y) {
            this.y = y;
            }
}
public class Object {
    public static void main(String[] args) {
/*
输出引用变量时默认调用Object类的toString()方法
该方法返回的字符串格式为: 类的全称@hashcode值
但通常这个返回结果对我们的开发是没有意义的
我们真正想输出的应该是对象的属性值
我们认为Object类的toString()并不能满足需求
因此我们常常重写toString()来返回具体的属性值
*/
        Point p = new Point(100,200);
        System.out.println(p);
        System.out.println(p.toString());
        Point po = new Point();
        System.out.println(po.toString());
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        po.setX(x);
        int y = scan.nextInt();
        po.setY(y);
        System.out.println(po.toString());
    }
}

